<?php
require_once "../Model/Poster.php";

class PostersTest extends PHPUnit_Framework_TestCase {
	
	public function setUp() {
		$this->poster = Poster::newWithXYTeamAndFileName(1, 1, 1, 'fileName');
				
	}
	
	public function tearDown() {
		OPDatabase::clear();
		
	}
	
	/**
	 * @test
	 */
	public function posterShouldHaveAnIdXYTeamFileNameAndDateTime() {
		
		$this->assertEquals(null, $this->poster->id());
		$this->assertEquals(1, $this->poster->x());
		$this->assertEquals(1, $this->poster->y());
		$this->assertEquals(1, $this->poster->team());
		$this->assertEquals('fileName', $this->poster->fileName());
		$this->assertEquals(date('Y-m-d H:i:s'), $this->poster->dateTime());
		
	}
	
	/**
	 * @test
	 */
	public function saveShouldAddAnEntryIntoTheDatabase() {
		$this->poster->save();

		$savedPoster = Poster::getPoster(1, 1);
		
		$this->assertEquals($this->poster->x(), $savedPoster->x());
		$this->assertEquals($this->poster->y(), $savedPoster->y());
		$this->assertEquals($this->poster->team(), $savedPoster->team());
		$this->assertEquals($this->poster->fileName(), $savedPoster->fileName());
		$this->assertEquals($this->poster->dateTime(), $savedPoster->dateTime());
		
	}
	
}